package com.example.cores_middle_activity;

import android.os.Bundle;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class RadioActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_radio);

        TextView tv_Result = findViewById(R.id.tv_result);
        RadioGroup radioGroup = findViewById(R.id.rd_group);

        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int id) {
                if (R.id.rd_male == id) {
                    tv_Result.setText("你是帅气的男孩");
                } else if (R.id.rd_female == id) {
                    tv_Result.setText("你是漂亮的女孩");
                }
            }
        });
    }
}